<div class="comm-top">
	<div class="title-left">
		数据列表
	</div>
	<div class="title-right">
    <form method="get" action="">
        <select name="sex" class="textarea">
            <option value=''>性别</option>
            <option value="1" <{if $smarty.get.sex==1}>selected<{/if}> >男</option>
            <option value="2" <{if $smarty.get.sex==2}>selected<{/if}> >女</option>
        </select>
        <{if $suserSession.type==2}>
        <select name="shop_id" class="textarea">
            <option value=''>所在门店</option>
            <{foreach from=$customerList item='pv'}>
                <option value="<{$pv.id}>" <{if $smarty.get.shop_id==$pv.id}>selected<{/if}> ><{$pv.name}></option>
            <{/foreach}>
        </select>
        <{elseif $suserSession.type==3}>
        <select name="group_id" class="textarea group_select">
            <option value=''>所在分组</option>
            <{foreach from=$groupRow key='pk' item='pv'}>
                <{if $pk==0}>
                    <option value="-1" <{if $smarty.get.group_id == '-1'}>selected<{/if}> ><{$pv}></option>
                <{else}>
                    <option value="<{$pk}>" <{if $smarty.get.group_id==$pk}>selected<{/if}> ><{$pv}></option>
                <{/if}>
            <{/foreach}>
        </select>
        <{/if}>
        <input name="p_c" class="textarea search_inp" placeholder="省份或城市" type="text" value="<{$smarty.get.p_c}>"/>
        <input name="nickname" class="textarea search_inp" placeholder="昵称" type="text" value="<{$smarty.get.nickname}>"/>
        <input value="查找" class="btn btn-success search_btn" type="submit" />
    </form>
	</div>
</div>
<div class="list-table">
	<div class="wrapper">
		<table class="stable">
			<thead>
				<tr>
					<th style="width:10px;"><input type="checkbox" id="checkAll" /></th>
					<th style="width:70px;">头像</th>
					<th>昵称</th>
					<th>性别</th>
					<th>所在省</th>
					<th>所在市</th>
                    <{if $suserSession.type==3}>
					<th>所在分组</th>
                    <{else}>
                    <th>所在门店</th>
                    <{/if}>
					<th>关注时间</th>
					<th>关注状态</th>
					<th>备注</th>
				</tr>
			</thead>
			<tbody>
                <form id="memberForm">
                <{foreach from=$list item=v}>
					<tr>
						<td><input type="checkbox" name="openid[]" value="<{$v.fromuser}>" /></td>
						<td><img src="<{$v.headimgurl|default:'../public/img/demault_head.jpg'}>" /></td>
						<td><{$v.nickname}></td>
						<td><{if $v.sex==1}>男<{elseif $v.sex==2}>女<{else}>-<{/if}></td>
						<td><{$v.province}></td>
						<td><{$v.city}></td>
                        <{if $suserSession.type==3}>
						<td><{$v.group_name}></td>
                        <{else}>
						<td><{$v.shop_name}></td>
                        <{/if}>
						<td><{$v.subscribe_time}></td>
						<td><{if $v.status==1}>已关注<{else}>已取消<{/if}></td>
						<td><input type="text" class="textarea" value="<{$v.des}>" id="des<{$v.id}>" onblur="edit_des(<{$v.id}>,this);" style="width:70px;" /></td>
					</tr>
                <{/foreach}>
                </form>
			</tbody>
		</table>
	</div>
</div>
<{if $suserSession.type==3}>
<div style="padding:10px;height:35px;line-height:35px;margin-bottom:20px;">
    <span style="height:35px;line-height:35px;display:inline-block;">批量移动至分组：</span>
    <select name="sex" class="textarea group_select" id="changeSelect" style="font-size:12px;min-width:100px;">
        <option value=''>请选择分组</option>
        <{foreach from=$groupRow key="pk" item='pv'}>
            <option value="<{$pk}>"><{$pv}></option>
        <{/foreach}>
    </select>
    <span class="btngreen30" onclick="changeGroup(this)" id="changeGroupBtn">确定</span>
</div>
<{/if}>
<{if $page}><div class="page-list"><{$page}></div><{/if}>
<script type="text/javascript">
$(function(){
    //ajax获取用户分组
    $.post('list.php',{a:'get_group'},function(res){
        if(res){
            var groupStr='';
            $.each(res,function(i,n){
                groupStr+="<option value='"+n.id+"'>"+n.name+"</option>";
            });
            $('.group_select').append(groupStr);
        }
    },'json');
    //复选框全选全不选
    $('#checkAll').click(function(){ 
        $('input[name="openid[]"]').attr("checked",this.checked); 
    });
})
//修改备注
function edit_des(id,obj){
    $.post('list.php',{id:id,a:'edit_des',des:$(obj).val()},function(res){
        res=$.trim(res);
        if(res=='suc'){
            note_info('修改成功',obj);
        }
    });
}
//移动分组
function changeGroup(obj){
    if($('#changeSelect').val()===''){
        note_info('请选择分组',obj,'warn');return;
    }
    if($("input[name='openid[]']:checked").length==0){
        note_info('请勾选相应用户',obj,'warn');return;
    }
    var layerLoad=layer.load(1,{shade:[0.1,'#666']});
    $.post('list.php?a=changeGroup&groupId='+$('#changeSelect').val(),$("#memberForm").serialize(),function(res){
        layer.close(layerLoad);
        res=$.trim(res);
        if(res=='suc'){
            note_info('移动分组成功',obj);
            setTimeout("window.location.reload()",1200);
        }else{
            note_info('移动分组失败',obj,'warn');
        }
    });
}
</script>